package com.yh.csx.business.api.exception;

import com.yh.csx.bsf.core.base.BsfLevel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * @创建人 霍钧城
 * @创建时间 2021年01月04日 13:54:00
 * @描述 异常详情
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ExceptionDetails implements Serializable {
    /** 异常状态码 */
    private int code;

    /** 提示信息 */
    private String message;

    /** 影响范围 */
    private String bizScope;

    /** 异常等级 */
    private int bizLevel=BsfLevel.LOW.getLevel();

    /** 异常详情 */
    private String bizDetails;

    private ExceptionDetails(Builder builder){
        this.code=builder.code;
        this.message=builder.message;
        this.bizLevel=builder.bizLevel;
        this.bizDetails=builder.bizDetails;
        this.bizScope=builder.bizScope;
    }
    public static Builder createBuilder(int code,String message){
        return new Builder(code,message);
    }
    public static class Builder{
        private int code;
        private String message;
        private int bizLevel=BsfLevel.LOW.getLevel();
        private String bizDetails;
        private String bizScope;

        private Builder(){}

        private Builder(int code,String message){
            this.code=code;
            this.message=message;
        }

        public Builder setBizLevel(int bizLevel) {
            this.bizLevel = bizLevel;
            return this;
        }

        public Builder setBizDetails(String bizDetails) {
            this.bizDetails = bizDetails;
            return this;
        }

        public Builder setBizScope(String bizScope) {
            this.bizScope = bizScope;
            return this;
        }

        public ExceptionDetails build(){
            return new ExceptionDetails(this);
        }
    }

}
